Allow to add inline parsers to built-in implementation#319
Closed
zampino wants to merge 1 commit intocommonmark:mainfrom
Closed
Allow to add inline parsers to built-in implementation#319zampino wants to merge 1 commit intocommonmark:mainfrom
zampino wants to merge 1 commit intocommonmark:mainfrom
Conversation
robinst
requested changes
Apr 11, 2024
Collaborator
robinst
left a comment
There was a problem hiding this comment.
So in order for users to actually use this, the configuration needs to be on the Parser.Builder, similar to custom block parsers. Then when constructing the inline parser, pass it in the constructor.
(We will also need to move some classes into an exported package, but can do that later.)
| } | ||
|
|
||
| public InlineParser addInlineParser(Character c, List<InlineContentParser> parsers) { | ||
| this.inlineParsers.put(c, parsers); |
Collaborator
There was a problem hiding this comment.
So this will currently override any existing built-in parsers with that same special character. I think we should do the same thing as for block parsers, see
So try the custom parsers first. The custom parser can decide not to handle something, in which case the built-in parsers are tried next.
Collaborator
|
Closing this in favor of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a minimal proposal for allowing the current internal implementation to customize inline parsing of special characters, following @robinst advice to provide a starting POC :-).
I quickly tested this in combination with
Parser.Builder.inlineParserFactoryin the context of a clojure application for parsing inline latex delimited between pairs of $ characters, but proper testing is still missing. It's a first step to see what's possible, far from providing enough fine-grained customization.Addresses #263. Closes #317.